package net.lab1024.sa.admin.module.business.orders.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.admin.module.business.orders.domain.form.RetailOrdersAddForm;
import net.lab1024.sa.admin.module.business.orders.domain.form.RetailOrdersQueryForm;
import net.lab1024.sa.admin.module.business.orders.domain.form.RetailOrdersUpdateForm;
import net.lab1024.sa.admin.module.business.orders.domain.vo.RetailOrdersVO;
import net.lab1024.sa.admin.module.business.orders.service.RetailOrdersService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 零售订单 Controller
 *
 * @Author 谭智得
 * @Date 2025-03-19 09:46:50
 * @Copyright 谭智得
 */

@RestController
@Tag(name = "")
public class RetailOrdersController {

    @Resource
    private RetailOrdersService retailOrdersService;

    @Operation(summary = "分页查询 @author 谭智得")
    @PostMapping("/retailOrders/queryPage")
    @SaCheckPermission("orders:query")
    public ResponseDTO<PageResult<RetailOrdersVO>> queryPage(@RequestBody @Valid RetailOrdersQueryForm queryForm) {
        return ResponseDTO.ok(retailOrdersService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 谭智得")
    @PostMapping("/retailOrders/add")
    @SaCheckPermission("orders:add")
    public ResponseDTO<String> add(@RequestBody @Valid RetailOrdersAddForm addForm) {
        return retailOrdersService.add(addForm);
    }

    @Operation(summary = "更新 @author 谭智得")
    @PostMapping("/retailOrders/update")
    @SaCheckPermission("orders:update")
    public ResponseDTO<String> update(@RequestBody @Valid RetailOrdersUpdateForm updateForm) {
        return retailOrdersService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 谭智得")
    @PostMapping("/retailOrders/batchDelete")
    @SaCheckPermission("orders:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return retailOrdersService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 谭智得")
    @GetMapping("/retailOrders/delete/{retailId}")
    @SaCheckPermission("orders:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer retailId) {
        return retailOrdersService.delete(retailId);
    }
}
